<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p>操作节点属性</p>
    <p class="p1"></p>
    <img class="img1" alt="immmmg">
    <script>
        var p1 = document.querySelector('.p1');
        var img = document.querySelector('.img1');
        p1.innerHTML = '我是一个普通的p标签';
        // 操作节点属性
        p1.setAttribute('title', '我是一名保安，爱吃小熊饼干，保卫一方平安，喜欢业主小丹');
        img.setAttribute('src', './1.png');
        img.setAttribute('width', 400);
        img.setAttribute('alt', '金牌保安')
        console.log(img.getAttribute('alt'));
        img.removeAttribute('alt')
    </script>
</body>

</html>